package com.qf.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.SessionAttributes;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/inter")
@SessionAttributes("user")
public class InterController {
    @RequestMapping("/login")
    public String login(Model model) {
//      用户登录后 信息存储在session作用域中
        model.addAttribute("user", "zhangsan");
        return "index";
    }

    @RequestMapping("/select")
    public String select(HttpSession session) {
//        Object user = session.getAttribute("user");
//        if(user==null){
//            return "redirect:/login.jsp";
//        }
//        调用业务跳转到 查询所有页面
        System.out.println("查询所有");
        return "show";
    }

    @RequestMapping("/update")
    public String insert(HttpSession session) {
//        Object user = session.getAttribute("user");
//        if(user==null){
//            return "redirect:/login.jsp";
//        }
//        调用业务跳转到修改页面
        return "update";
    }

}
